<?php

     session_start();


     $action = filter_var($_POST['action'], FILTER_SANITIZE_STRING);

     switch($action){
               case 'login':
                    $usr = $_POST['res'];
                    $usr = json_decode($usr);

                    $_SESSION['dni'] = $usr->{'dni'};
                    $_SESSION['connected'] = true;
                    $_SESSION['nombre'] =  $usr->{'nombre'};

               break;
               case 'logout':
                    $_SESSION = array();
                    session_destroy();
               break;

     }



?>